home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / edit / me_cd25.zip / MUTT2.ZIP / CASE.MUT < prev    next >
Lisp/Scheme  |  1992-11-09  |  2KB  |  63 lines

  1. ;; case.mut
  2. ;; Case Conversion Routines.
  3. ;; Should be the same routine names and functionality as GNU Emacs.
  4. ;; Differences:
  5. ;;   If a mark is in the region being cased, it will be moved to the front
  6. ;;    of the region because the region is deleted ie I don't change the
  7. ;;    text in place.
  8. ;; C Durland 2/91    Public Domain
  9.  
  10. (include me2.h)
  11.  
  12. (const
  13.   LOWER-CASE    0
  14.   UPPER-CASE    1
  15.   CAPITALIZE    2
  16. )
  17.  
  18. (defun MAIN
  19. {
  20.   (bind-to-key "downcase-region"    "C-xC-l")
  21.   (bind-to-key "upcase-region"        "C-xC-u")
  22.  
  23.   (bind-to-key "downcase-word"        "M-l")
  24.   (bind-to-key "upcase-word"        "M-u")
  25.   (bind-to-key "capitalize-word"    "M-c")
  26. })
  27.  
  28. (defun
  29.   case-region (int op mark1 mark2) HIDDEN
  30.   {
  31.     (int bag)
  32.     (byte type)(small-int left-edge width height)(int size)    ;; RegionInfo
  33.  
  34.     (region-stats (loc type) mark1 mark2 TRUE)
  35.  
  36.     (bag (create-bag))
  37.     (append-to-bag bag APPEND-CHARACTERS size)
  38.     (case-bag op bag)
  39.     (arg-prefix size)(delete-character)
  40.     (insert-bag bag)
  41.     (free-bag bag)
  42.   }
  43.   downcase-region   { (case-region LOWER-CASE THE-DOT THE-MARK) }
  44.   upcase-region        { (case-region UPPER-CASE THE-DOT THE-MARK) }
  45.   capitalize-region { (case-region CAPITALIZE THE-DOT THE-MARK) }
  46. )
  47.  
  48. (defun
  49.   case-word (int n op)
  50.   {
  51.     (int mark1 mark2)
  52.  
  53.     (mark1 (create-mark)) (mark2 (create-mark))
  54.     (set-mark mark1)
  55.     (arg-prefix n)(next-word)(set-mark mark2)
  56.     (case-region op mark1 mark2)
  57.     (free-mark mark1 mark2)
  58.   }
  59.   downcase-word      { (case-word (arg-prefix) LOWER-CASE) }
  60.   upcase-word      { (case-word (arg-prefix) UPPER-CASE) }
  61.   capitalize-word { (case-word (arg-prefix) CAPITALIZE) }
  62. )
  63.